package com.shop.front.dao.user;


import com.shop.jpa.BaseSQLDao;
import com.shop.jpa.support.QuerySQL;
import com.shop.domain.user.UserBankCard;
import com.shop.web.context.WebContext;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Repository;

@Repository
public class UserBankCardSQLDao extends BaseSQLDao {

    public Page<UserBankCard> page(Long userId,String cardType) {
        StringBuffer field = new StringBuffer("ua.*");
        String from = "t_user_bank_card ua";
        String order = "ua.is_default desc, ua.id desc";
        QuerySQL qs = new QuerySQL(WebContext.getPageNo(), WebContext.getPageSize(), field.toString(), from, order);
        qs.addWhereWithoutParams("ua.is_deleted = 0");
        qs.addWhereEq("ua.user_id", userId);
        qs.addWhereEq("ua.card_type", cardType);
        return this.page(qs, UserBankCard.class);
    }

}
